﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DbHelp;

namespace IotherRis
{
    public partial class Fr_add_pid : DevExpress.XtraEditors.XtraForm
    {
        public Fr_add_pid()
        {
            InitializeComponent();
        }
        string mIid = "";
        uDataSetC mUds = null;
        public Fr_add_pid(string pIid)
        {
            InitializeComponent();
            mIid = pIid;
        }

        private void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                mUds.SetItem(1, "BODYPART", txt_bodypart.Text);
                mUds.SetItem(1, "MODALITY", txt_modality.Text);
                mUds.SetItem(1, "TEMPLATE_NAME", txt_name.Text);
                mUds.SetItem(1, "IPID", "0");
                mUds.Update(AccessHelper.mReportDb);
                MessageBox.Show("保存成功");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败");
            }

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string mSql = "select * from pi_reporttemplate where iid=-1 AND IPID=0";
            mUds = new uDataSetC(mSql, AccessHelper.mReportDb);
            //if (mUds.RowCount() >= 1)
            //{
            //    txt_bodypart.Text = mUds.GetItemString(1, "BODYPART");
            //    txt_modality.Text = mUds.GetItemString(1, "MODALITY");
            //    txt_name.Text = mUds.GetItemString(1, "TEMPLATE_NAME");

            //}
            //else
            //{
            mUds.InsertRow();
            txt_bodypart.Text = "";
            txt_modality.Text = "";
            txt_name.Text = "";
            //}

        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
